package com.itheima.a01immutable;

import java.util.Map;
import java.util.Set;

public class ImmutableDemo3 {
    public static void main(String[] args) {
        //一旦创建完毕后，是无法进行修改的，在下面的代码中，只能进行查询操作
        Map<String, String> map = Map.of("张三", "南京", "李四", "北京", "王五", "上海", "赵六", "广州", "孙七", "深圳", "周八", "杭州", "吴九", "宁波", "郑十", "苏州",
                "刘一", "无锡", "陈二", "嘉兴");
        Set<String> keys = map.keySet();
        for (String key : keys) {
            String value = map.get(key);
            System.out.println(key+" = " + value);
        }
        System.out.println("-------------------------------");

        Set<Map.Entry<String, String>> entries = map.entrySet();
        for (Map.Entry<String, String> entry : entries) {
            String key = entry.getKey();
            String value = entry.getValue();
            System.out.println(key+" = " + value);
        }
        System.out.println("-------------------------------");
    }

    //如果我想让这个方法能接收多个键和值
    //解决方案:
    //键 可变参数 值 可变参数
    //类型不确定:泛型方法

}
